package edu.gatech.oad.mule;
import java.io.Serializable;

import edu.gatech.oad.mule.config.interfaces._ConfigurationPanel;

/**
 * This class represents a Player's Wallet. A Wallet is a collection of 
 * resources that a Player can acquire throughout the game (ex: smithore,
 * food, energy, crystite).
 *
 * @author Brendan McGarry, Dale Avery, D'Miria Collins, Natasha Parekh, Jaemin Park
 * @version %I%, %G%
 */
public class Wallet implements Serializable{
	
	private static final long serialVersionUID = -6394016689305907703L;
	
	//The resources a player keeps in his wallet
	int crystite;
	int energy;
	int food;
	int money;
	int smithore;
	
	/**
	 * This constructor configures a new empty Wallet object
	 */
	public Wallet(){
		//these are the default starting resources for a
		//  non-human, non-flapper player with a beginner
		//  difficulty.  The human and flapper races get
		//  a different starting money and the difficulty
		//  will change the amount of starting resources
		this(0, 2, 4, 1000, 0);
	}//end null constructor
	
	/**
	 * This constructor configures a new wallet with the following
	 * starting values:
	 * 
	 * @param crystite The starting amount of crystite this wallet has
	 * @param energy The starting amount of energy this wallet has
	 * @param food The starting amount of food this wallet has
	 * @param money The starting amount of money this wallet has
	 * @param smithore The starting amount of smithore this wallet has
	 */
	public Wallet(int crystite, int energy, int food, int money, int smithore){
		this.crystite = crystite;
		this.energy = energy;
		this.food = food;
		this.money = money;
		this.smithore = smithore;
	}//end constructor

	/**
	 * Creates the Player's wallet and gives the player
	 * starting resources based on the player's race and the
	 * difficulty of the game chosen.
	 *
	 * @param panel A reference to the configuration GUI to get
	 * preferences
	 */
	public Wallet(_ConfigurationPanel panel, String race){
		//other constructor call
		this();
		//get difficulty
		String difficulty = panel.getDifficulty();
		//set up the starting resources.  check what difficulty
		//  was chosen.  beginner mode each player starts with 
		//  twice as much stuff
		if(difficulty == "Beginner"){
			setFood(8);
			setEnergy(4);
			setSmithore(0);
		}//end else

		//flappers get a positive handicap
		if(race == "Flapper"){
			setMoney(1600);
		}//end if
		//humans get a negative handicap
		else if(race == "Human"){
			setMoney(600);
		}//end else if
	}//end constructor

	/**
	 * @param amount The amount of crystite to add to the player's
	 * wallet.  Can be negative, zero, or positive value.
	 */
	public void addCrystite(int amount){
		crystite += amount;
	}//end method addCrystite

	/**
	 * @param amount The amount of energy to add to the player's
	 * wallet.  Can be negative, zero, or positive value.
	 */
	public void addEnergy(int amount){
		energy += amount;
	}//end method addEnergy

	/**
	 * @param amount The amount of food to add to the player's
	 * wallet.  Can be negative, zero, or positive value.
	 */
	public void addFood(int amount){
		food += amount;
	}//end method addFood

	/**
	 * @param amount The amount of money to add to the player's
	 * wallet.  Can be negative, zero, or positive value.
	 */
	public void addMoney(int amount){
		money += amount;
	}//end method addMoney

	/**
	 * @param amount The amount of smithore to add to the player's
	 * wallet.  Can be negative, zero, or positive value.
	 */
	public void addSmithore(int amount){
		smithore += amount;
	}//end method addSmithore

	/**
	 * @return The amount of crystite the player owns
	 */
	public int getCrystite(){
		return crystite;
	}//end method getCrystite

	/**
	 * @return The amount of energy the player owns
	 */
	public int getEnergy(){
		return energy;
	}//end method getEnergy
	
	/**
	 * @return The amount of food the player owns
	 */
	public int getFood(){
		return food;
	}//end method getFood
	
	/**
	 * @return The amount of money the player has
	 */
	public int getMoney(){
		return money;
	}//end method getMoney

	/**
	 * @return The amount of smithore the player owns
	 */
	public int getSmithore(){
		return smithore;
	}//end method getSmithore

	/**
	 * @param crystite The new amount of crystite
	 */
	public void setCrystite(int crystite){
		this.crystite = crystite;
	}//end method setCrystite

	/**
	 * @param energy The new amount of energy
	 */
	public void setEnergy(int energy){
		this.energy = energy;
	}//end method setEnergy

	/**
	 * @param food The new amount of food
	 */
	public void setFood(int food){
		this.food = food;
	}//end method setFood

	/**
	 * @param money The new amount of money
	 */
	public void setMoney(int money){
		this.money = money;
	}//end method setMoney

	/**
	 * @param smithore The new amount of smithore
	 */
	public void setSmithore(int smithore){
		this.smithore = smithore;
	}//end method setSmithore

	/**
	 * @return A string representation of this wallet
	 */
	public String toString(){
		return ("crystite: " + crystite + "\nfood: " + food + "\nenergy: " + energy + "\nsmithore: " + smithore + "\nmoney: " + money);
	}//end method toString

}//end class Wallet
